package com.example.heraclitoapp;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager.NameNotFoundException;

public class Utils {
	
	public static Builder createDialogHelper(Context context, CharSequence title, CharSequence message, boolean OnlyNeutralButton) {
		
		AlertDialog.Builder dialog = new AlertDialog.Builder(
				context);
		dialog.setTitle(title);
		dialog.setMessage(message);
		
		if (OnlyNeutralButton == true) {
			dialog.setNeutralButton(R.string.okButtonText, null);
			dialog.show();
		}

		return dialog;
	}
	
	public static Builder createDialogHelper(Context context, int title, int message, boolean OnlyNeutralButton) {
		return createDialogHelper(context, context.getText(title), context.getText(message), OnlyNeutralButton);
	}
	
	public static Builder createDialogHelper(Context context, int title, String message, boolean OnlyNeutralButton) {
		return createDialogHelper(context, context.getText(title), message, OnlyNeutralButton);
	}
	
	public static String getVersion(Context context) {
		String versionName = null;
		try {
			versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
		} catch (NameNotFoundException e) {
			// do nothing
		}
		return versionName;
	}
	
}